﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using MVVMLightDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVVMLightDemo.ViewModel
{
    public class ComboBoxViewModel:ViewModelBase
    {

        private RelayCommand<string> selectedChangedCommand;

        public RelayCommand<string> SelectedChangedCommand
        {
            get
            {
                return selectedChangedCommand;
            }
            set
            {
                selectedChangedCommand = value;
            }
        }

        public List<BoyInfo> listBoyInfo { get; set; }

        private List<Fruit> listFruit;

        public List<Fruit> ListFruit
        {
            get
            {
                return listFruit;
            }
            set
            {
                listFruit = value;
                this.RaisePropertyChanged(nameof(ListFruit));
            }
        }



        public ComboBoxViewModel()
        {
            listBoyInfo = new List<BoyInfo>();
            BoyInfo info1 = new BoyInfo { Name = "111", Age = 12, ListFavo = new List<string> { "女人", "男人", "游泳" } };
            BoyInfo info2 = new BoyInfo { Name = "222", Age = 44, ListFavo = new List<string> { "女人", "男人", "游泳" } };
            BoyInfo info3 = new BoyInfo { Name = "334", Age = 1252, ListFavo = new List<string> { "女人", "男人", "游泳" } };
            BoyInfo info4 = new BoyInfo {Name= "554",Age = 124 ,ListFavo = new List<string> {"女人","男人","游泳" } };
            listBoyInfo.Add(info1);
            listBoyInfo.Add(info2);
            listBoyInfo.Add(info3);
            listBoyInfo.Add(info4);

            SelectedChangedCommand = new RelayCommand<string>((p)=>
            {
                var list = listBoyInfo;
            });

            ListFruit = new List<Fruit>
            {
                new Fruit {Name = "Apple",Price = Faker.RandomNumber.Next(5,10).ToString() },
                new Fruit {Name = "Banana",Price = Faker.RandomNumber.Next(5,10).ToString() },
                new Fruit {Name = "Orange",Price = Faker.RandomNumber.Next(5,10).ToString() },
                new Fruit {Name = "WaterMelon",Price = Faker.RandomNumber.Next(5,10).ToString() },
                new Fruit {Name = "HaMiGua",Price = Faker.RandomNumber.Next(5,10).ToString() },
            };
        }
    }
}
